package org.my.spring.agent.common.core.config;

import org.my.spring.agent.common.core.service.ServiceFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.ServiceLocatorFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 服务工厂配置类
 * 用于创建ServiceFactory实例，通过服务定位器模式实现服务的动态查找和注入
 */
@Configuration
public class ServiceFactoryConfig {

    /**
     * 创建服务定位器工厂Bean
     * 
     * @return FactoryBean实例，用于生成ServiceFactory接口的实现
     */
    @Bean("serviceFactory")
    public FactoryBean<?> serviceLocatorFactoryBean() {
        ServiceLocatorFactoryBean serviceFactory = new ServiceLocatorFactoryBean();
        serviceFactory.setServiceLocatorInterface(ServiceFactory.class);
        return serviceFactory;
    }
}
